package com.pw.gmall.realtime.function;

import com.pw.gmall.realtime.utils.AtguiguUtils;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.ArrayList;

/**
 * @Author: linux_future
 * @since: 2022/3/28
 **/
@FunctionHint(output = @DataTypeHint("row<word string>"))
public class IKAnalyzer extends TableFunction<Row> {

    public void eval(String kw) {
        ArrayList<String> words = AtguiguUtils.splitByIkAnalyze(kw);
        for (String word : words) {
            collect(Row.of(word));
        }
    }
}
